<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 主页</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
     <!-- Data Tables -->
    <link href="{$Think.config.site.resource_url}css/animate.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.css?v=4.1.0" rel="stylesheet">
</head>
<style>
    .fa{ color:#1ab394;  cursor:pointer;}
</style>
<body >
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
            <style type="text/css">.col-sm-12 label{ font-weight:300; }</style>
                <div class="ibox float-e-margins">
                    <div class="">
                        <h5>{:lang('客户详情')}</h5>
                    </div>
                    <div class="row ibox-title">
                    <form action="" method="post" name="payjilu">　
                        <label >{:lang('手机号')}:</label>
                        <label ><input type="text" class="input-sm form-control" name="mobile" id="mobile" aria-controls="" placeholder="{:lang('输入')} {:lang('手机号')}" value="{$mobile ?? ''}"></label>　　　
                        <label >{:lang('用户名')}:</label>
                        <label ><input type="text" class="input-sm form-control" aria-controls="" name="name" placeholder="{:lang('输入')} {:lang('用户名')}" value="{$name ?? ''}"></label>
                        <label><button type="submit" class="btn btn-sm btn-primary" id="btn"> {:lang('提交')}</button> </label>
                        </form>
                    </div>
                    <div class="ibox-content">

                        <table class="table table-hover" id="listtable">
                            <thead>
                                <tr>
                                    <th>{:lang('头像')}</th>
                                    <th>{:lang('用户名')}</th>
                                    <th>{:lang('手机号')}</th>
                                    <th>{:lang('性别')}</th>
                                    <th>{:lang('地区')}</th>
                                    <th>{:lang('余额')}</th>
                                    <th>{:lang('押金金额')}</th>
                                    <th>{:lang('创建时间')}</th>
                                    <th>{:lang('操作')}</th>
                                </tr>
                            </thead>
                            <tbody>
                            {volist name="list" id="v"}
                                <tr data-id="{$v.id}">
                                    <td><img src="{$v.picture}" alt=""width="30" height="30"></td>
                                    <td>{$v.name}</td>
                                    <td>{$v.mobile}</td>
                                    <td>
                                        {switch name="v.gender"}
                                            {case value="1"}{:lang('男')}{/case}
                                            {case value="2"}{:lang('女')}{/case}
                                            {case value="0"}{:lang('保密')}{/case}
                                        {/switch}
                                    </td>
                                    <td>{$v.province} {$v.city}</td>
                                    <td>{$v.balance}</td>
                                    <td>{$v.deposit}</td>
                                    <td>{$v.create_time|date="Y-m-d H:i:s",###}</td>
                                    <td><select class="form-control action" name="account" data-id="{$v.id}" style="width:60%" >
                                        <option value="">{:lang('选择操作类型')}</option>
                                        <option value="1">{:lang('编辑用户')}</option>
                                        <option value="2">{:lang('余额设置')}</option>
                                        <option value="6">{:lang('押金设置')}</option>
                                        {if condition="$v['cdeposit'] neq ''"}<option value="3">{:lang('押金退款')}</option>{/if}
                                        {if condition="$v['cbalance'] neq ''"}<option value="5">{:lang('余额退款')}</option>{/if}
                                        <option value="4">{:lang('删除用户')}</option>
                                    </select></td>
                                </tr> 
                            {/volist}
                            </tbody>
                        </table>
                    </div>

                    <div class="row">
                        <div class="col-sm-6">
                            <div class="dataTables_info" id="DataTables_Table_0_info" role="alert" aria-live="polite" aria-relevant="all"></div>
                        </div>
                        <div class="col-sm-6">
                            <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                {$page}
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.6"></script>
    <!-- Peity -->
    <script src="{$Think.config.site.resource_url}js/plugins/peity/jquery.peity.min.js"></script>
    <!-- 自定义js -->
    <script src="{$Think.config.site.resource_url}js/content.js?v=1.0.0"></script>
    <!-- iCheck -->
    <script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
            $('#btn').click(function(){
                var tel = $('#mobile').val();
                var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                if(tel!=''){

                    if(tel.length !=11){
                        $("#mobile").val('');
                        $("#mobile").attr('placeholder',"{:lang('请输入正确的手机号码')}");
                        $('#mobile').css('borderColor','red');
                        $("#mobile").focus();
                        
                        return false;
                    }
                    if(!myreg.test(tel)){
                        $("#mobile").val('');
                        $("#mobile").attr('placeholder',"{:lang('请输入正确的手机号码')}");
                        $('#mobile').css('borderColor','red');
                        $("#mobile").focus();
                         return false;
                    }
                }
                
                return;
            });
        });
    </script>

    <script src="{$Think.config.site.resource_url}js/plugins/layer/laydate/laydate.js"></script>
    <script type="text/javascript">
        var layer_font;
        var $editTr;
        $(function(){
            //修改按钮
            $("#listtable").on("click",".fa-edit",function(){
                $editTr = $(this).closest("tr");
                var id = $editTr.data("id");
                layer_font = layer.open({
                  type: 2,
                  title: "{:lang('更新操作')}",
                  shadeClose: true,
                  shade: 0.8,
                  area: ['80%', '90%'],
                  content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Customer/edit?id='+id //iframe的url
                });
            });
            $("#listtable").on("click",".fa-trash-o",function(){
                var $tr = $(this).closest("tr");
                var id = $tr.data("id");
            });

            $('.action').change(function(){
                var a = $(this).val();
                var id = $(this).data('id');
                //
                if(a !=''){
                    if(a==4){
                        layer.confirm("{:lang('确定要删除？')}", {
                        btn: ["{:lang('确定删除')}","{:lang('不删除')}"], //按钮
                        shade: false //不显示遮罩
                        }, function(){
                            //确定删除
                            $.ajax({
                                type : 'POST',//delete
                                url : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Customer/delete?id='+id,
                                dataType : 'json',
                                data : {id:id},
                                async:false,
                                success : function(result) {
                                    //layer.close(layer1);
                                    if(0 === result.code) {
                                        window.location.reload();
                                        $tr.remove();
                                        layer.msg(result.msg, {icon: 1});
                                    }  else  {
                                        //删除失败
                                        layer.msg(result.msg, {icon: 5});
                                    }
                                },
                                error : function(){
                                    res = false;
                                    layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                                }
                            })
                        },
                        function(){
                            
                        });  
                    }
                    if(a==1){
                        layer_font = layer.open({
                          type: 2,
                          title: "{:lang('更新操作')}",
                          shadeClose: true,
                          shade: 0.8,
                          area: ['80%', '90%'],
                          content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Customer/edit?id='+id //iframe的url
                        });
                    }

                    if(a==2){
                        layer_font = layer.open({
                          type: 2,
                          title: "{:lang('客户金额变动')}",
                          shadeClose: true,
                          shade: 0.8,
                          area: ['40%', '50%'],
                          content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Orders/change?id='+id //iframe的url
                        });
                    }

                    if(a==3){
                        layer.confirm("{:lang('确定要退押金？')}", {
                        btn: ["{:lang('确定')}","{:lang('取消')}"], //按钮
                        shade: false //不显示遮罩
                        }, function(){
                            //确定删除
                            $.ajax({
                                type : 'POST',//delete
                                url : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Orders/deposit',
                                dataType : 'json',
                                data : {id:id},
                                async:false,
                                success : function(result) {
                                    //layer.close(layer1);
                                    if(0 == result.code) {
                                        window.location.reload();
                                        layer.msg(result.msg, {icon: 1});
                                    }  else  {
                                        //删除失败
                                        layer.msg(result.msg, {icon: 5});
                                    }
                                },
                                error : function(){
                                    res = false;
                                    layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                                }
                            })
                        },
                        function(){
                            
                        });
                    } 
                    if(a==5){
                        layer_font = layer.open({
                          type: 2,
                          title: "{:lang('客户余额退款')}",
                          shadeClose: true,
                          shade: 0.8,
                          area: ['50%', '70%'],
                          content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Customer/balance?id='+id //iframe的url
                        });
                    }
                    //押金设置
                    if(a==6){
                        layer_font = layer.open({
                          type: 2,
                          title: "{:lang('客户押金金额手动设置')}",
                          shadeClose: true,
                          shade: 0.8,
                          area: ['50%', '70%'],
                          content: '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Customer/deposit?id='+id //iframe的url
                        });
                    }

                }
            });
        });
    </script>
</body>

</html>
